/*
 * @Author       : NaN 353362604@qq.com
 * @Date         : 2023-01-12 09:35:49
 * @LastEditTime : 2023-07-06 15:15:00
 * @LastEditors  : NaN 353362604@qq.com
 * @FilePath     : \AdminStration\src\Common\Router\MenuNav\TwoRouter\ProjectCompanyMonthReport.jsx
 * @Description  :
 */
import dayjs from 'dayjs'
import { API_LIST } from '../../../Api/Api'
import { AddDataButton, DelDataButton, CommonButton } from '../Common/options'

export const ProjectCompanyMonthReport = async ({ OptionsEvent, oneData, Permission }) => {
    let dataList = {
        hideInSearch: true,
        pageSize: 10,
        initialValues: { organizationUuid: oneData.organizationUuid },
        params: { OrderField: 'yearMonth@desc', organizationUuid: oneData.organizationUuid },
        classification: 'TableModal',
        get: API_LIST([oneData.uuid])['getProjectCompanyMonthReport'],
        added: 'posProjectCompanyMonthReport',
        options: [
            Permission.findIndex(v => v.uuid === 'ae1980ed-9e0f-4922-967b-0ab62008ed0e') !== -1 && (
                <AddDataButton OptionsEvent={OptionsEvent} type="primary" icon="add" title="添加月报" />
            ),
        ],
        columns: [
            {
                dataIndex: 'organizationUuid',
                title: 'organizationUuid',
                valueType: 'hidden',
                hideInTable: true,
            },
            {
                dataIndex: 'tableName',
                title: '月报名称',
                valueType: 'automatically',
                addonBefore: '工程月报',
                addonField: 'yearMonth',
                addonType: 'yearMonth',
                initialValues: oneData.organization.tableName,
            },
            {
                dataIndex: 'yearMonth',
                title: '月报月份',
                valueType: 'Date',
                picker: 'month',
                rules: true,
                render: (_, { yearMonth }) => <div>{dayjs(yearMonth).format('YYYY-MM')}</div>,
            },
            {
                title: '创建时间',
                dataIndex: 'createTime',
                valueType: 'input',
                hideInTable: true,
                hideInAdded: true,
                hideInModify: true,
            },
            {
                title: '操作',
                valueType: 'systemOperation',
                fixed: 'right',
                width: 500,
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
                render: (_, record) => {
                    const { tableName } = record
                    return [
                        <CommonButton
                            key="RichText"
                            OptionsEvent={OptionsEvent}
                            title="月报附件"
                            data={{
                                smallTitle: `${tableName} 月报附件`,
                                type: 'CompanyAttachment',
                                record,
                                Permission,
                                OptionsEvent,
                            }}
                        />,
                        Permission.findIndex(v => v.uuid === 'de0277a1-0229-48d3-82e8-76d22656f391') !== -1 && (
                            <DelDataButton
                                OptionsEvent={OptionsEvent}
                                key="del"
                                title="删除"
                                url="ProjectCompanyMonthReport"
                                uuid={record.uuid}
                            />
                        ),
                    ]
                },
            },
        ],
    }
    return dataList
}
